package org.lql.algo.codecrush.week001;

/**
 * @author: liangqinglong
 * @date: 2025-07-23 16:11
 * @description: LCR 122. 路径加密 <a href="https://leetcode.cn/problems/ti-huan-kong-ge-lcof/description/">...</a>
 **/
public class PathEncryption {


	/**
	 * 假定一段路径记作字符串 path，其中以 "." 作为分隔符。现需将路径加密，加密方法为将 path 中的分隔符替换为空格 " "，请返回加密后的字符串。
	 * <p>
	 * 示例 1：
	 * <p>
	 * 输入：path = "a.aef.qerf.bb"
	 * <p>
	 * 输出："a aef qerf bb"
	 */
	public String pathEncryption(String path) {
		int length = path.length();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < length; i++) {
			if (path.charAt(i) == '.') {
				sb.append(" ");
			} else {
				sb.append(path.charAt(i));
			}
		}
		return sb.toString();
	}

	public static void main(String[] args) {
		PathEncryption pathEncryption = new PathEncryption();
		System.out.println(pathEncryption.pathEncryption("a.aef.qerf.bb"));
	}
}
